package com.atguigu.sellcourse.dao

import org.apache.spark.sql.SparkSession

/**
 * description ：售课模块读取数据层
 * author      ：剧情再美终是戏 
 * mail        : 13286520398@163.com
 * date        ：Created in 2020/3/10 15:00
 * modified By ：
 * version:    : 1.0
 */
object DwdSellCourseDao {

  /**
   * 读取售课支付表
   *
   * @Author 剧情再美终是戏
   * @Date 2020/3/10 15:04
   * @param spark sparkSession
   * @param dt    日期分区
   * @param dn    地区分区
   * @return java.lang.Object
   * @Version 1.0
   **/
  def getCoursePay(spark: SparkSession, dt: String, dn: String) = {
    spark.sql(
      s"""
         |select
         |   orderid,
         |   discount,
         |   paymoney,
         |   createtime,
         |   dt,
         |   dn
         |from dwd.dwd_course_pay
         |where dt = ${dt} and dn = ${dn}
         |""".stripMargin)
  }


  /**
   * 读取售课支付表 分桶表
   *
   * @Author 剧情再美终是戏
   * @Date 2020/3/10 15:04
   * @param spark sparkSession
   * @param dt    日期分区
   * @param dn    地区分区
   * @return java.lang.Object
   * @Version 1.0
   **/
  def getCoursePayBuket(spark: SparkSession, dt: String, dn: String) = {
    spark.sql(
      s"""
         |select
         |   orderid,
         |   discount,
         |   paymoney,
         |   createtime,
         |   dt,
         |   dn
         |from dwd.dwd_course_pay_buket
         |where dt = ${dt} and dn = ${dn}
         |""".stripMargin)
  }

  /**
   * 读取售课表数据
   *
   * @Author 剧情再美终是戏
   * @Date 2020/3/10 15:04
   * @param spark sparkSession
   * @param dt    日期分区
   * @param dn    地区分区
   * @return java.lang.Object
   * @Version 1.0
   **/
  def getSaleCourse(spark: SparkSession, dt: String, dn: String) = {
    spark.sql(
      s"""
         |select
         |   courseid,
         |   coursename,
         |   status,
         |   pointlistid,
         |   majorid
         |   chapterid,
         |   chaptername,
         |   edusubjectname,
         |   teacherid,
         |   teachername,
         |   coursemanager,
         |   money,
         |   dt,
         |   dn
         |from dwd.dwd_sale_course
         |where dt = ${dt} and dn = ${dn}
         |""".stripMargin)
  }

  /**
   * 读取购物车模块表
   *
   * @Author 剧情再美终是戏
   * @Date 2020/3/10 15:04
   * @param spark sparkSession
   * @param dt    日期分区
   * @param dn    地区分区
   * @return java.lang.Object
   * @Version 1.0
   **/
  def CourseShoppingCart(spark: SparkSession, dt: String, dn: String) = {
    spark.sql(
      s"""
         |select
         |   courseid,
         |   orderid,
         |   coursename,
         |   discount,
         |   sellmoney,
         |   createtime,
         |   dt,
         |   dn
         |from dwd.dwd_course_shopping_cart
         |where dt = ${dt} and dn = ${dn}
         |""".stripMargin)
  }

  /**
   * 读取购物车模块表 分桶表
   *
   * @Author 剧情再美终是戏
   * @Date 2020/3/10 15:04
   * @param spark sparkSession
   * @param dt    日期分区
   * @param dn    地区分区
   * @return java.lang.Object
   * @Version 1.0
   **/
  def CourseShoppingCartBuket(spark: SparkSession, dt: String, dn: String) = {
    spark.sql(
      s"""
         |select
         |   courseid,
         |   orderid,
         |   coursename,
         |   discount,
         |   sellmoney,
         |   createtime,
         |   dt,
         |   dn
         |from dwd.dwd_course_shopping_cart_buket
         |where dt = ${dt} and dn = ${dn}
         |""".stripMargin)
  }

}
